
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Dubbo 的扩展点有哪些？如何自定义扩展点？ - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>Dubbo 的扩展点有哪些？如何自定义扩展点？ - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">Dubbo的扩展点机制提供了哪些方面的自定义能力？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Dubbo提供了丰富的扩展点，允许用户根据需求自定义和扩展其功能，覆盖了包括协议、序列化、负载均衡、容错机制、过滤器和线程池等多个方面。</div>
          </div>
          <div class="card-source">来源: 文档开篇及 1. Dubbo 的扩展点</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">Dubbo中的协议扩展（Protocol）主要负责什么功能？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">协议扩展（Protocol）定义了Dubbo的通信协议，主要负责服务的远程调用和数据传输。常见的实现有 dubbo、rmi 和 hessian 协议。</div>
          </div>
          <div class="card-source">来源: 1.1 协议扩展（Protocol）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">序列化扩展（Serialization）在Dubbo中的核心作用是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">序列化扩展的核心作用是负责将对象序列化为字节流，以及将字节流反序列化为对象，从而确保数据能够在网络中正确传输。</div>
          </div>
          <div class="card-source">来源: 1.2 序列化扩展（Serialization）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Dubbo的负载均衡扩展（LoadBalance）是如何工作的？请列举三种常见的实现。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">负载均衡扩展的功能是决定请求如何在多个服务提供者之间进行分配。常见实现包括：random（随机）、roundrobin（轮询）和 leastactive（最少活跃调用）。</div>
          </div>
          <div class="card-source">来源: 1.3 负载均衡扩展（LoadBalance）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">当服务调用失败时，Dubbo的哪种扩展点会介入处理？它的功能是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">容错机制扩展（Failover）会介入处理。它的功能是定义服务调用失败后的处理策略，例如重试（failover）、快速失败（failfast）或安全失败（failsafe）等。</div>
          </div>
          <div class="card-source">来源: 1.4 容错机制扩展（Failover）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">过滤器扩展（Filter）的主要用途是什么？并举例说明。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">过滤器扩展允许在服务调用前后进行自定义的逻辑处理。例如，`logging` 过滤器用于日志记录，`monitor` 过滤器用于性能监控，`auth` 过滤器用于认证。</div>
          </div>
          <div class="card-source">来源: 1.5 过滤器扩展（Filter）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">如何通过Dubbo的SPI机制注册一个自定义的扩展类？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">要注册一个自定义扩展类，需要在 `META-INF/dubbo` 目录下创建一个以扩展接口全限定名命名的文件，然后在该文件中以`key=value`的形式指定扩展名和实现类的全限定名。例如，对于LoadBalance接口，文件内容可以是 `custom=your.package.CustomLoadBalance`。</div>
          </div>
          <div class="card-source">来源: 2.1 编写自定义扩展类</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在不修改XML配置的情况下，如何在Java代码中主动加载一个已注册的自定义扩展点？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">可以使用 `ExtensionLoader` 类来加载。例如，要加载一个名为 `custom` 的 `LoadBalance` 扩展，可以使用代码：`LoadBalance loadBalance = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension("custom");`。</div>
          </div>
          <div class="card-source">来源: 2.1 编写自定义扩展类</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">Dubbo的线程池扩展（Executor）是用来做什么的？它有哪些常见实现？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">线程池扩展用于管理线程池的配置和调度，以控制服务的并发处理能力。常见的实现有 `fixed`（固定大小线程池）和 `cached`（缓存线程池）。</div>
          </div>
          <div class="card-source">来源: 1.6 线程池扩展（Executor）</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
